package com.ftf.tp.blog.application.service.representation.impl;

import com.ftf.tp.blog.application.assembler.QuestionAssembler;
import com.ftf.tp.blog.application.dto.QuestionPageDTO;
import com.ftf.tp.blog.application.service.representation.QuestionRepresentation;
import com.ftf.tp.blog.application.vo.QuestionVO;
import com.ftf.tp.blog.domain.configuration.dos.QuestionDO;
import com.ftf.tp.blog.domain.configuration.repository.QuestionRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author tanghao
 * @date 2022/8/11
 */
@Slf4j
@Service
public class QuestionRepresentationImpl implements QuestionRepresentation {

    @Resource
    private QuestionRepository questionRepository;

    /**
     * 问题分页
     *
     * @param questionPageDTO 分页参数
     * @return 分页结果
     */
    @Override
    public List<QuestionVO> pageQuestion(QuestionPageDTO questionPageDTO) {
        List<QuestionDO> questionDOList = questionRepository
                .pageQuestion(QuestionAssembler.INSTANCE.dtoToDO(questionPageDTO));
        return QuestionAssembler.INSTANCE.doToVoList(questionDOList);
    }
}
